<template>
  <el-table :data="userArray">
    <el-table-column label="序号" type="index"></el-table-column>
    <el-table-column label="用户名" prop="userName"></el-table-column>
    <el-table-column label="昵称" prop="nickName"></el-table-column>
    <el-table-column label="部门" prop="depId"></el-table-column>
    <el-table-column label="头像" prop="avatar"></el-table-column>
    <el-table-column label="邮箱" prop="email"></el-table-column>
    <el-table-column label="电话" prop="mobile"></el-table-column>
    <el-table-column label="积分" prop="score"></el-table-column>
    <el-table-column label="状态" prop="status"></el-table-column>
    <el-table-column label="管理员" prop="isAdmin"></el-table-column>
    <el-table-column label="角色" prop="roles"></el-table-column>
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button type="text" :disabled="user.id==scope.row.id"
                   @click="deleteUser(scope.$index,scope.row)">删除
        </el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
export default {
  name: "UserList",
  data(){
    return{
      userArray:[{userName: '', nickName: '',avatar:'',email:'',mobile:'',score:'',status:'',isAdmin:'',roles:'',depId:''}],
      user:localStorage.user ? JSON.parse(localStorage.user) : "",
    }
  },
  created:function () {
    this.$http.get("/users").then((response)=> {
      if (response.data.code == 1) {
        this.userArray = response.data.data;
      } else {
        alert("无权访问!");
        location.href = "/";
      }
    })
  }
}
</script>

<style scoped>

</style>